package com.ruoyi.yer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yer.domain.YerXc;
import com.ruoyi.yer.service.IYerXcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 幼儿园管理Controller
 * 
 * @author ruoyi
 * @date 2022-10-07
 */
@RestController
@RequestMapping("/yer/xc")
public class YerXcController extends BaseController
{
    @Autowired
    private IYerXcService yerXcService;

    /**
     * 查询幼儿园管理列表
     */
    @PreAuthorize("@ss.hasPermi('yer:xc:list')")
    @GetMapping("/list")
    public TableDataInfo list(YerXc yerXc)
    {
        startPage();
        List<YerXc> list = yerXcService.selectYerXcList(yerXc);
        return getDataTable(list);
    }

    /**
     * 导出幼儿园管理列表
     */
    @PreAuthorize("@ss.hasPermi('yer:xc:export')")
    @Log(title = "幼儿园管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YerXc yerXc)
    {
        List<YerXc> list = yerXcService.selectYerXcList(yerXc);
        ExcelUtil<YerXc> util = new ExcelUtil<YerXc>(YerXc.class);
        util.exportExcel(response, list, "幼儿园管理数据");
    }

    /**
     * 获取幼儿园管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('yer:xc:query')")
    @GetMapping(value = "/{yerId}")
    public AjaxResult getInfo(@PathVariable("yerId") Long yerId)
    {
        return AjaxResult.success(yerXcService.selectYerXcByYerId(yerId));
    }

    /**
     * 新增幼儿园管理
     */
    @PreAuthorize("@ss.hasPermi('yer:xc:add')")
    @Log(title = "幼儿园管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YerXc yerXc)
    {
        return toAjax(yerXcService.insertYerXc(yerXc));
    }

    /**
     * 修改幼儿园管理
     */
    @PreAuthorize("@ss.hasPermi('yer:xc:edit')")
    @Log(title = "幼儿园管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YerXc yerXc)
    {
        return toAjax(yerXcService.updateYerXc(yerXc));
    }

    /**
     * 删除幼儿园管理
     */
    @PreAuthorize("@ss.hasPermi('yer:xc:remove')")
    @Log(title = "幼儿园管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yerIds}")
    public AjaxResult remove(@PathVariable Long[] yerIds)
    {
        return toAjax(yerXcService.deleteYerXcByYerIds(yerIds));
    }
}
